package core.database;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity(name = "core.ElectionVoter")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "electionVoters")
public class ElectionVoter<V extends Voter<?>, E extends Election<?>> implements Serializable {
	private static final long serialVersionUID = 3310134027335962398L;
	
	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id = null;
	@ManyToOne
	@JoinColumn(name = "voter", insertable = false, updatable = true)
	private V voter;
	@ManyToOne
	@JoinColumn(name = "election", insertable = false, updatable = true)
	private E election;

	public Long getId() {
		return id;
	}

	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}

	public V getVoter() {
		return voter;
	}

	public void setVoter(V voter) {
		this.voter = voter;
	}

	public E getElection() {
		return election;
	}

	public void setElection(E election) {
		this.election = election;
	}

}
